<h1>New purchase</h1>
  <script language="javascript" type="text/javascript">
    function item_loading() {
        Element.show('busy');
    }
    function item_added() {
        Element.hide('busy');
        $('quantity').value = '';
        $('quantity').focus();
    }
</script>


<%= start_form_tag :action => 'create' %>
  <%= render :partial => 'form' %>
  <%= submit_tag "Create" %>
<%= end_form_tag %>

<hr/>

<%= form_remote_tag(
    :url => { :action => 'add_item' },
    :update => 'purchase_item_list',
    :loading => 'item_loading()',
    :complete => 'item_added();'
    )
%>
    <%= text_field_tag('purchase_item[quantity]' , '', :id => 'quantity') %>
    <%= %>
    <%= submit_tag "Add new Item" %>
    <span id="busy" style="display:none">Adding...</span>
<%= end_form_tag %>

<%= end_form_tag %>
<div id="purchase_item_list">
</div>
<%= link_to 'Back', :action => 'list' %>
